


# 订单信息定义
order_no = "DH202311010001"
order_time = "2023-11-01 20:56:15"
products = [
    {"name": "金士顿U盘8G", "quantity": 1, "unit_price": 40.00, "amount": 40.00},
    {"name": "胜创16GTF卡", "quantity": 1, "unit_price": 50.00, "amount": 50.00},
    {"name": "读卡器", "quantity": 1, "unit_price": 8.00, "amount": 8.00},
    {"name": "网线2米", "quantity": 1, "unit_price": 5.00, "amount": 5.00},
    {"name": "圣杯", "quantity": 1, "unit_price": 99.00, "amount": 99.00}
]
total_quantity = len(products)
discount_rate = 0.98  # 9.8折
received = 200.00  # 实收金额（可根据实际情况调整）

# 计算商品金额、总额等
for p in products:
    p["amount"] = p["quantity"] * p["unit_price"]
total_quantity = sum(p["quantity"] for p in products)
total_amount = sum(p["amount"] for p in products)
discounted_amount = round(total_amount * discount_rate, 2)  # 折扣后金额
change = round(received - discounted_amount, 2)  # 找零

# 分隔线（根据内容长度设置）
separator = "-" * 50

# 打印订单
print(f"单号: {order_no}")
print(f"时间: {order_time}")
print(separator)
# 商品表头
print(f"{'名称':<20}{'数量':>6}{'单价':>10}{'金额':>10}")
# 商品列表
for p in products:
    print(f"{p['name']:<20}{p['quantity']:>6}{p['unit_price']:>10.2f}{p['amount']:>10.2f}")
print(separator)
# 统计信息
print(f"总数: {total_quantity:<10} " " "f"总额:{total_amount:.2f}")
print(f"折扣: 9.8折")
print(f"折后总额: {discounted_amount:.2f}")
print(f"实收: {received:.2f}      找零: {change:.2f}")
print(f"收银员: 管理员")
print(separator)



